package com.itheima.utils;

import com.alibaba.fastjson.JSON;
import com.itheima.pojo.ResultMessage;

public class MessageUtil {
    public static String getMessage(boolean isSystemMessage, String fromName, String cause, Object message) {
        ResultMessage resultMessage = new ResultMessage();
        resultMessage.setSystem(isSystemMessage);
        resultMessage.setMessage(message);
        if (fromName != null) {
            resultMessage.setFromName(fromName);
        }
        if (cause != null) {
            resultMessage.setCause(cause);
        }
        return JSON.toJSONString(resultMessage);
    }
}
